package cn.maihe.elg.operation.supports.electronicseal.kt;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description
 * @Author WJH
 * @Date 2021/04/26
 */
@Configuration
@ConfigurationProperties(prefix = "cn.maihe.elg.kt")
@Data
public class KtConfig {

    private String serverUrl;
    /**
     * 凯特云签配置
     */
    private CloudSign cloudSign;

    /**
     * key=签章公司枚举Name value 签章信息
     */
    private Map<String, SealInfo> sealInfoMap = new HashMap<>();

    @Data
    public static class SealInfo {
        //公章印章Id
        private String sealId;
        //公章签章密码
        private String certIndexPassWd;
        //法人章印章Id
        private String legalSealId;
        //法人章签章密码
        private String legalCertIndexPassWd;
    }

    public SealInfo getSealInfoByKey(SealInstitution sealInstitution) {
        return this.sealInfoMap.get(sealInstitution.name());
    }

    public enum SealInstitution {
        deXing("得兴担保公司印章"),
        zhongTian("中天担保公司印章");

        SealInstitution(String institutionName) {
            this.institutionName = institutionName;
        }

        private String institutionName;

        public String getInstitutionName() {
            return institutionName;
        }
    }

    @Data
    public static class CloudSign {
        private String registServer;
        private String contractServer;
        private String appId;
        private String key;
        private String secret;
        /**
         * ofd云签服务ip:端口
         */
        private String ofdServer;

    }
}
